package responsibility.my;



/**
 * @Author: Doream
 * @Date: 2022/1/29 21:45
 */
// 抽象处理者
public abstract class HandlerPeople {
    // 可处理的最大天数
    private int maxHandleNumber;
    // 不可处理时，交给上级领导(后继者)
    private HandlerPeople next;

    public HandlerPeople(int maxHandleNumber, HandlerPeople next) {
        this.maxHandleNumber = maxHandleNumber;
        this.next = next;
    }

    public void handle(LeaveRequest leaveRequest){
        if (leaveRequest.getNum()<=this.maxHandleNumber){
            handleMode(leaveRequest);
        } else if (this.next!=null){
            this.next.handle(leaveRequest);
        }else {
            System.out.println("不予批准");
        }
    }
    protected abstract void handleMode(LeaveRequest leaveRequest);
}
